-- SQL Manager 2010 for PostgreSQL 4.7.0.2
-- ---------------------------------------
-- Хост         : 77.88.207.250
-- База данных  : europaplus
-- Версия       : PostgreSQL 8.3.11 on i386-portbld-freebsd8.0, compiled by GCC cc (GCC) 4.2.1 20070719  [FreeBSD]



--
-- Definition for function f_any_on_update (OID = 1212373) : 
--
SET search_path = public, pg_catalog;
SET check_function_bodies = false;
CREATE FUNCTION public.f_any_on_update (
)
RETURNS trigger
AS 
$body$
BEGIN
  NEW.t_updated := 'now'::timestamp(0) with time zone;
  RETURN NEW;
END;
$body$
    LANGUAGE plpgsql;
--
-- Definition for sequence global_id_seq (OID = 1212374) : 
--
CREATE SEQUENCE public.global_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;

--
-- Structure for table consts (OID = 1212390) : 
--
CREATE TABLE public.consts (
    id integer DEFAULT nextval('global_id_seq'::regclass) NOT NULL,
    t_created timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
    t_updated timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
    pid_profile_addby integer NOT NULL,
    key character varying(32) NOT NULL,
    value character varying(255) NOT NULL,
    workstatus smallint DEFAULT 1 NOT NULL
) WITH OIDS;
--
-- Structure for table content (OID = 1212397) : 
--
CREATE TABLE public.content (
    id integer DEFAULT nextval('global_id_seq'::regclass) NOT NULL,
    t_created timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
    t_updated timestamp without time zone,
    pid_profile_addby integer NOT NULL,
    workstatus smallint DEFAULT 1 NOT NULL,
    pubdate timestamp without time zone,
    type character varying(20) NOT NULL,
    name text NOT NULL,
    anons text,
    description text,
    source_static character varying(255),
    order_index integer DEFAULT (-1) NOT NULL,
    CONSTRAINT content__workstatus CHECK ((workstatus = ANY (ARRAY[0, 1, 2, 3])))
) WITHOUT OIDS;

--
-- Structure for table logos (OID = 1212413) : 
--
CREATE TABLE public.logos (
    id integer DEFAULT nextval('global_id_seq'::regclass) NOT NULL,
    t_created timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
    t_updated timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
    pid_profile_addby integer NOT NULL,
    name character varying(255) NOT NULL,
    workstatus smallint DEFAULT 1 NOT NULL
) WITH OIDS;
--
-- Structure for table media (OID = 1212420) : 
--
CREATE TABLE public.media (
    id integer DEFAULT nextval('global_id_seq'::regclass) NOT NULL,
    t_created timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
    t_updated timestamp without time zone,
    pid_profile_addby integer,
    gid character varying(48) NOT NULL,
    pid integer,
    width integer,
    height integer,
    description text,
    order_index integer DEFAULT 0 NOT NULL,
    extension character varying(16)
) WITHOUT OIDS;
--
-- Structure for table profiles (OID = 1212429) : 
--
CREATE TABLE public.profiles (
    id integer DEFAULT nextval('global_id_seq'::regclass) NOT NULL,
    t_created timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
    t_updated timestamp without time zone,
    pid_profile_addby integer,
    workstatus smallint DEFAULT 0 NOT NULL,
    email character varying(64) NOT NULL,
    fname character varying(64) NOT NULL,
    lname character varying(64),
    passwd character(32) NOT NULL,
    sex character varying(6),
    birthday date,
    description text,
    confirm_code character varying(32),
    permissions integer DEFAULT 0 NOT NULL,
    is_has_avatar smallint DEFAULT 0 NOT NULL,
    is_dj_online smallint DEFAULT 0 NOT NULL,
    order_index integer DEFAULT (-1) NOT NULL,
    CONSTRAINT profiles__sex CHECK ((((sex)::text = 'male'::text) OR ((sex)::text = 'female'::text))),
    CONSTRAINT profiles__workstatus CHECK ((((workstatus = 0) OR (workstatus = 1)) OR (workstatus = 2)))
) WITHOUT OIDS;
--
-- Structure for table singlepages (OID = 1212444) : 
--
CREATE TABLE public.singlepages (
    id integer DEFAULT nextval('global_id_seq'::regclass) NOT NULL,
    t_created timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
    t_updated timestamp without time zone,
    tid character varying(32) NOT NULL,
    pid_profile_addby integer NOT NULL,
    name character varying(255) NOT NULL,
    description text NOT NULL,
    "group" character varying(32)
) WITHOUT OIDS;


--
-- Data for table public.profiles (OID = 1212429) (LIMIT 0,13)
--

INSERT INTO profiles (id, pid_profile_addby, workstatus, email, fname, lname, passwd, sex, birthday, description, confirm_code, permissions, is_has_avatar, is_dj_online, order_index)
VALUES (1, null, 1, 'Lenon1@bigmir.net', 'Дима', 'яя', 'a23363729d5988ff8b43b36805d8be98', 'male', '1990-06-09', NULL, NULL, 1, 1, 0, -1);

--
-- Data for table public.singlepages (OID = 1212444) (LIMIT 0,4)
--

INSERT INTO singlepages (id, t_created, t_updated, tid, pid_profile_addby, name, description, "group")
VALUES (125, '2010-03-23 16:20:01', '2010-05-18 16:45:17', 'contacts', 1, 'Контакты', '<p><strong>КИЕВСКИЙ ОФИС</strong></p>
<p><strong>Адрес:</strong> Украина, 04080, Киев, ул.Фрунзе, 39, 5 этаж, <b>Европа Плюс</b><br /><b>Телефоны/факсы:</b> +3 (044) 5-020-022, +3 (044) 5-020-023, +3 (044) 5-020-024</p>
<p><strong>ДИРЕКЦИЯ ПРОГРАММ:</strong></p>
<p><strong>Анастасия Гордиенко</strong> - генеральный продюсер, программный директор</p>
<p><a title="Написать письмо" target="_blank" href="mailto:a.gordienko@radiogroup.com.ua">Написать письмо</a></p>
<p><strong>МУЗЫКАЛЬНАЯ РЕДАКЦИЯ:</strong></p>
<p><strong>Роман Давыдов</strong> - музыкальный редактор</p>
<p><a title="Написать письмо" target="_blank" href="mailto:r.budivskiy@radiogroup.com.ua">Написать письмо</a></p>
<p><strong>ТЕХНИЧЕСКАЯ ПОДДЕРЖКА САЙТА:</strong></p>
<p><strong>Елена Таржанова </strong>- администратор сайта</p>
<p><a title="Написать письмо" target="_blank" href="mailto:e.tarzhanova@radiogroup.com.ua">Написать письмо</a></p><a title="Редакционный Устав" target="_blank" href="/store/public/Редакционный%20устав.doc">
  <p><strong>РЕДАКЦИОННЫЙ УСТАВ</strong></p>
  <p><a title="Редакционный Устав" target="_blank" href="/store/public/Редакционный%20устав.doc"></a></p></a>', NULL);

--
-- Definition for index content__type__idx (OID = 1212494) : 
--
CREATE INDEX content__type__idx ON content USING btree (type);
--
-- Definition for index media_gid (OID = 1212495) : 
--
CREATE INDEX media_gid ON media USING btree (gid);
--
-- Definition for index media_pid (OID = 1212496) : 
--
CREATE INDEX media_pid ON media USING btree (pid);
--
-- Definition for index profiles_email_unique (OID = 1212497) : 
--
CREATE UNIQUE INDEX profiles_email_unique ON profiles USING btree (email);
--
-- Definition for index singlepages_tid_uni (OID = 1212498) : 
--
CREATE UNIQUE INDEX singlepages_tid_uni ON singlepages USING btree (tid);

--
-- Definition for index consts__pkey (OID = 1212479) : 
--
ALTER TABLE ONLY consts
    ADD CONSTRAINT consts__pkey PRIMARY KEY (id);
--
-- Definition for index content_pkey (OID = 1212481) : 
--
ALTER TABLE ONLY content
    ADD CONSTRAINT content_pkey PRIMARY KEY (id);

--
-- Definition for index logos_pkey (OID = 1212485) : 
--
ALTER TABLE ONLY logos
    ADD CONSTRAINT logos_pkey PRIMARY KEY (id);
--
-- Definition for index media_pkey (OID = 1212487) : 
--
ALTER TABLE ONLY media
    ADD CONSTRAINT media_pkey PRIMARY KEY (id);
--
-- Definition for index profiles_pkey (OID = 1212489) : 
--
ALTER TABLE ONLY profiles
    ADD CONSTRAINT profiles_pkey PRIMARY KEY (id);
--
-- Definition for index singlepages_pkey (OID = 1212491) : 
--
ALTER TABLE ONLY singlepages
    ADD CONSTRAINT singlepages_pkey PRIMARY KEY (id);
--
-- Definition for index consts__pid_profile_addby__fk (OID = 1212511) : 
--
ALTER TABLE ONLY consts
    ADD CONSTRAINT consts__pid_profile_addby__fk FOREIGN KEY (pid_profile_addby) REFERENCES profiles(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- Definition for index content__pid_profile_addby__fk (OID = 1212516) : 
--
ALTER TABLE ONLY content
    ADD CONSTRAINT content__pid_profile_addby__fk FOREIGN KEY (pid_profile_addby) REFERENCES profiles(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- Definition for index logos__pid_profile_addby__fk (OID = 1212531) : 
--
ALTER TABLE ONLY logos
    ADD CONSTRAINT logos__pid_profile_addby__fk FOREIGN KEY (pid_profile_addby) REFERENCES profiles(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- Definition for index media__pid_profile_addby__fk (OID = 1212536) : 
--
ALTER TABLE ONLY media
    ADD CONSTRAINT media__pid_profile_addby__fk FOREIGN KEY (pid_profile_addby) REFERENCES profiles(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- Definition for index profiles__pid_profile_addby__fk (OID = 1212541) : 
--
ALTER TABLE ONLY profiles
    ADD CONSTRAINT profiles__pid_profile_addby__fk FOREIGN KEY (pid_profile_addby) REFERENCES profiles(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- Definition for index singlepages__pid_profile_addby__fk (OID = 1212546) : 
--
ALTER TABLE ONLY singlepages
    ADD CONSTRAINT singlepages__pid_profile_addby__fk FOREIGN KEY (pid_profile_addby) REFERENCES profiles(id) ON UPDATE CASCADE ON DELETE SET NULL;
--
-- Definition for trigger content_on_update (OID = 1212500) : 
--
CREATE TRIGGER content_on_update
    BEFORE UPDATE ON content
    FOR EACH ROW
    EXECUTE PROCEDURE f_any_on_update ();
--
-- Definition for trigger logos_on_update (OID = 1212501) : 
--
CREATE TRIGGER logos_on_update
    BEFORE UPDATE ON logos
    FOR EACH ROW
    EXECUTE PROCEDURE f_any_on_update ();
--
-- Definition for trigger logos_on_update (OID = 1212502) : 
--
CREATE TRIGGER logos_on_update
    BEFORE UPDATE ON consts
    FOR EACH ROW
    EXECUTE PROCEDURE f_any_on_update ();
--
-- Definition for trigger media_on_update (OID = 1212503) : 
--
CREATE TRIGGER media_on_update
    BEFORE UPDATE ON media
    FOR EACH ROW
    EXECUTE PROCEDURE f_any_on_update ();
--
-- Definition for trigger profiles_on_update (OID = 1212504) : 
--
CREATE TRIGGER profiles_on_update
    BEFORE UPDATE ON profiles
    FOR EACH ROW
    EXECUTE PROCEDURE f_any_on_update ();
--
-- Definition for trigger singlepages_on_update (OID = 1212505) : 
--
CREATE TRIGGER singlepages_on_update
    BEFORE UPDATE ON singlepages
    FOR EACH ROW
    EXECUTE PROCEDURE f_any_on_update ();
--
-- Comments
--
COMMENT ON SCHEMA public IS 'standard public schema';
